<%@tag pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@tag import="com.oplink.webems.modules.sys.entity.Config"%>
<%@ attribute name="catalog"  type="java.lang.String" required="false"%>
<ul id="tab_nav" class="nav nav-tabs">
<c:forEach items="${fns:getModuleList(catalog)}" var="item">
	<!-- 有子表单 -->					
	<c:if test="${!empty item.childFormList }">
		<c:forEach items="${fns:getChildFormList(item.childFormList)}" var="childType">						
			<li><a href="#${childType}" data-toggle="tab">${fns:getDictLabel(0, childType, 'N/A')}</a></li>			 		
		</c:forEach>		
	</c:if>
</ul>
<div id="tab_cont" style="height: 75%;" class="tab-content">
<c:if test="${!empty item.childFormList }">
		<c:forEach items="${fns:getChildFormList(item.childFormList)}" var="childContent">									 		
			<div class="tab-pane active" id="${childContent}">
				<widgets:form withYesNo="${childContent}" catalog="${childContent}"></widgets:form>
			</div>
		</c:forEach>	
</c:if>		
</c:forEach>
</div>
<script>
	//组装修改过的数据
	var changedValue = {};

	$(document).ready(function() {
		initControllers()
		initData();
		initEvent();		
	});

	/**
	 * 初始化数据
	 */
	function initData() {
		$('input').each(function(index, data) {
			//文本框输入值
			$(data).keyup(function() {
				var beforeValue = parent.commonAPI.INITIAL_MAP[data.id];
				if (beforeValue != $(this).val()) {
					changedValue[data.id] = $(this).val();
					$("#valListChanged").val(JSON.stringify(changedValue));
				}
			});
		});
	}
	/**
	 * 初始化相关事件
	 */
	function initEvent() {

	}
	/**
	 * 初始化相关控件
	 */
	function initControllers() {
		$('.date-picker').datetimepicker({
			autoclose : true,
			format : 'yyyy-mm-dd',
			weekStart : 1,
			todayBtn : 'linked',
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});

		$('.time-picker').datetimepicker({
			autoclose : true,
			format : 'hh:ii:ss',
			weekStart : 1,
			todayBtn : 'linked',
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});	
		
		/* $('.time-picker').timepicker({
			minuteStep : 1,
			showSeconds : true,
			showMeridian : false
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});	 */	
				
		//增加滑动条
		$('.scrollPanel').mCustomScrollbar({theme:"minimal-dark"});
	}
	
	/**
	  * 设置要提交的值
	  **/
	function setChangeValue(field){
		changedValue[field.attr('name')] = field.val();
		$("#valListChanged").val(JSON.stringify(changedValue));
	}
	
	/**
	  * 获取当前参数列表
	  */
	function getParamList() {
		var paramStr = '';		
		$('.fieldNameList').each(function(index,data){
			paramStr += $(data).val() ;
		});	
		paramStr = paramStr.substr(1);
		var paramList = paramStr.split("|");
		return paramList;
	}
	
	/**
	  * 返回生成值
	  **/
	function getAllValue() {
		var outData = {};
		$(paramList).each(function(index, key){
			var item = $('#' + key);
			if(!item.attr('readonly')){
				var value = item.val();
				outData[key] = value;
			}
		});
		return JSON.stringify(outData);
	}
</script>